// ValidationAspects
// Written by Mike Saunders
// Released under Microsoft Public License (Ms-PL)
using NUnit.Framework;
using ValidationAspects.Exceptions;

namespace TestValidationAspects.Exceptions
{
	[TestFixture]
	public class TestValidateNotNullOrEmptyException
	{
		[SetUp]
		public void SetUp()
		{
			ValidateNotNullOrEmptyException.ResetMessageFormat();
		}

		[Test]
		public void Test_default_MessageFormat()
		{
			ValidateNotNullOrEmptyException exception = new ValidateNotNullOrEmptyException();
			Assert.AreEqual(exception.GetValidationTargetName() + " is required.", ValidateNotNullOrEmptyException.MessageFormat(exception));
		}

		[Test]
		public void Test_get_Message_executes_MessageFormat()
		{
			const string message = "custom message";
			ValidateNotNullOrEmptyException.MessageFormat = e => message;
			Assert.AreEqual(message, new ValidateNotNullOrEmptyException().Message);
		}

		[Test]
		public void Test_ResetMessageFormat()
		{
			const string message = "custom message";
			ValidateNotNullOrEmptyException.MessageFormat = e => message;

			ValidateNotNullOrEmptyException exception = new ValidateNotNullOrEmptyException();
			Assert.AreEqual(message, exception.Message);

			ValidateNotNullOrEmptyException.ResetMessageFormat();
			Assert.AreEqual(exception.GetValidationTargetName() + " is required.", ValidateNotNullOrEmptyException.MessageFormat(exception));
		}
	}
}